import {request} from "umi"
import {delNullProperty} from "@/utils/handle";

/**
 * 登录接口
 * @param account
 * @param password
 */
export async function login(account: string, password: string) {
  return request<ABIS.Result<string>>(
    '/api/accounts/login',
    {
      method: 'POST',
      data: {
        account: account,
        password: password
      },
      requestType: "form"
    }
  )
}

/**
 * 获取当前账号的菜单
 */
export function menus() {
  return request<ABIS.ResultList<ABIS.Menu>>(
    '/api/accounts/menus'
  )
}

/**
 * 获取当前账号信息
 */
export function accountInfo() {
  return request<ABIS.Result<ABIS.Account>>(
    '/api/accounts/info'
  )
}

/**
 * 获取账号列表，分页
 */
export function accounts(params: any) {
  delNullProperty(params)
  return request<ABIS.Pagination<ABIS.Account>>(
    '/api/accounts/page',
    {
      params
    }
  )
}

/**
 * 获取所有账号
 */
export function accountList() {
  return request<ABIS.ResultList<ABIS.AccountListItem>>(
    '/api/accounts/list'
  )
}

